package com.aiwiown.snackmq.console.web;

import com.aiwiown.snackmq.console.service.SnackMQAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/brokers")
public class BrokerController {

    @Autowired
    private SnackMQAdminService adminService;

    @GetMapping
    public String listBrokers(Model model) {
        try {
            model.addAttribute("brokers", adminService.listBrokers());
        } catch (Exception e) {
            model.addAttribute("error", "Failed to fetch broker list: " + e.getMessage());
        }
        return "brokers"; // 对应 brokers.html
    }
}